<?php

namespace app\api\controller;

use app\common\controller\Api;

class Monitor extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 监控列表
     * @return void
     */
    public function list()
    {

        $param = $this->request->param();
        $url="/nsj9201/stream/cameraChannelList";
        $urlse=$this->Monitor_url($url);
        $data=json_encode($param, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
        $response=$this->curl_data($urlse,$data);
//        dump($response);die;
        //这里取到值后需要处理
        foreach ($response['resultData']['list'] as $k=>$v){
            $response['resultData']['list'][$k]['streamUrl']=$v['streamUrl'].$this->Monitor_sign();
        }
        //好了这里处理完成 要 返回给前端了
        $this->success('',$response);
    }

    /**
     * 摄像头控制
     * @return void
     */
    public function CameraPtz()
    {
        $param = $this->request->param();
        $url="/nsj9201/stream/controlCameraPtz";
        $urlse=$this->Monitor_url($url);
        $data=json_encode($param, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
        $response=$this->curl_data($urlse,$data);
        //好了这里处理完成 要 返回给前端了
        $this->success('',$response);
    }

    /**
     * 开始录像回放
     * @return string
     */
    public function startPlayBack()
    {
        $param = $this->request->param();
        $url="/nsj9201/stream/startPlayBack";
        $urlse=$this->Monitor_url($url);
        $data=json_encode($param, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
        $response=$this->curl_data($urlse,$data);
        //好了这里处理完成 要 返回给前端了
        $this->success('',$response);
    }
    /**
     * 设置回放速度
     * @return string
     */
    public function setPlayBackSpeed()
    {
        $param = $this->request->param();
        $url="/nsj9201/stream/setPlayBackSpeed";
        $urlse=$this->Monitor_url($url);
        $data=json_encode($param, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
        $response=$this->curl_data($urlse,$data);
        //好了这里处理完成 要 返回给前端了
        $this->success('',$response);
    }

    /**
     * 回放暂停/恢复
     * @return void
     */
    public function pausePlayBack()
    {
        $param = $this->request->param();
        $url="/nsj9201/stream/pausePlayBack";
        $urlse=$this->Monitor_url($url);
        $data=json_encode($param, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
        $response=$this->curl_data($urlse,$data);
        //好了这里处理完成 要 返回给前端了
        $this->success('',$response);
    }

}
